# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Slash <demodevil5[at]yahoo[dot]com>
# Contributor: Babets
# Contributor: Vain
# Contributor: Aleksej Komarov <stylemistake@gmail.com>

pkgname='warsow'
pkgver=2.1.2
pkgrel=2
pkgdesc='Free online multiplayer competitive FPS based on the Qfusion engine'
url='https://www.warsow.net/'
license=('GPL')
arch=('loong64' 'x86_64')
depends=('sdl2' 'libjpeg' 'libpng' 'curl' 'libvorbis' 'freetype2'
         'libxinerama' 'libxxf86vm' 'libxrandr' 'libtheora' 'libxi')
makedepends=('imagemagick' 'gendesk')
optdepends=('openal: for openal audio support')
provides=('warsow')
conflicts=('warsow')
source=('warsow.png'
        'warsow.launcher'
        'wsw-server.launcher'
        'wswtv-server.launcher'
        "https://warsow.net/warsow-${pkgver}.tar.gz")
sha512sums=('85e6d42f2abb6da01781758133d15906996c67ddfbcb2aba0ceecc7cbc8f8d0905fbfa1aa1e5b503099af268f1eac7c68a0cc31cab50fe23b679f37cef7f4f59'
            '0c4e1debeb8f5aa826e89390c1e38236d5a3c500db9de8cede85d5fa25f1d4893545740175faf3a23b6a51ec8a63c14c6b3fdaca20f4b8bfb21290c092c070bb'
            '877279ff7201e411ecec933bc829c30ae5f5135ce30ef93063dca5c13d3c838091cfc847db4264fa2080cc3df24ace3e848555617a1a85d53446d3662f64ed93'
            '2bb689098ccf88b2b7b12e6382c17c31e9363c53a3e9e4168b5cc9fa8103894928072b923b68460d284d3e8cc051c1e69f3d53790298628c5ed0b7921e80c6bf'
            'c26971882c6ddad7e2a2e65c61bc2a327b9690a18b8faeabb23931a3d21a5d34bfac0a27516dfd39898419daaf607f48053754024e6a0ed66cfdccda34134c15')

prepare() {
  gendesk -n -f --pkgname 'warsow' --pkgdesc "${pkgdesc}" --name 'Warsow' --categories 'Game;ActionGame'
}

package() {
  for wbin in warsow{,.x86_64} wsw_server{,.x86_64} wswtv_server{,.x86_64}; do
    install -Dm755 warsow-${pkgver}/${wbin} "${pkgdir}/opt/warsow/${wbin}"
  done
  cp -a warsow-${pkgver}/{basewsw,libs,docs} "${pkgdir}/opt/warsow/"

  find "${pkgdir}/opt/warsow"/{basewsw,libs,docs} -type d | xargs chmod 755
  find "${pkgdir}/opt/warsow"/{basewsw,libs,docs} -type f | xargs chmod 644

  # Install launchers to /usr/bin
  install -D -m 0755 "${srcdir}/warsow.launcher" "${pkgdir}/usr/bin/warsow"
  install -D -m 0755 "${srcdir}/wsw-server.launcher" "${pkgdir}/usr/bin/wsw-server"
  install -D -m 0755 "${srcdir}/wswtv-server.launcher" "${pkgdir}/usr/bin/wswtv-server"

  # Install the menu entry
  install -D -m 0644 "${srcdir}/warsow.desktop" "${pkgdir}/usr/share/applications/warsow.desktop"

  # Install the launcher icon
  install -D -m 0644 "${srcdir}/warsow.png" "${pkgdir}/usr/share/pixmaps/warsow.png"
}

# vim: ts=2 sts=2 et:
